import request from '@/utils/request'

export function getOpinions() {
  return request({
    url: '/opinion/find',
    method: 'get',
  })
}

export function getNews() {
  return request({
    url: '/news/find',
    method: 'get',
  })
}

export function getKnowledge() {
  return request({
    url: '/knowledge/find',
    method: 'get',
  })
}

export function getAqs() {
  return request({
    url: '/aq/find',
    method: 'get',
  })
}


export function deleteNews(news_id) {
  return request({
    url: '/news/delete',
    method: 'delete',
    data:{
      news_id,
    }
  })
}

export function deleteOpinion(opinion_id) {
  return request({
    url: '/opinion/delete',
    method: 'delete',
    data:{
      opinion_id,
    }
  })
}

export function deleteKnowledge(knowledge_id) {
  return request({
    url: '/knowledge/delete',
    method: 'delete',
    data:{
      knowledge_id,
    }
  })
}

export function deleteAq(aq_id) {
  return request({
    url: '/aq/delete',
    method: 'delete',
    data:{
      aq_id,
    }
  })
}

export function createAq(question,answer,answers) {
  return request({
    url: '/aq/create',
    method: 'post',
    data:{
      question,answer,answers
    }
  })
}

export function createKnowledge(content,title) {
  return request({
    url: '/knowledge/create',
    method: 'post',
    data:{
      content,
      title,
    }
  })
}


export function updateKnowledge(content,title,knowledge_id) {
  return request({
    url: '/knowledge/update',
    method: 'post',
    data:{
      content,
      title,
      knowledge_id,
    }
  })
}

export const addKnowledgeImg = (data) => request({
  url: '/img/addKnowledges',
  method: 'POST',
  data
})

export function createNews(content,title) {
  return request({
    url: '/news/create',
    method: 'post',
    data:{
      content,
      title,
    }
  })
}


export function updateNews(content,title,news_id) {
  return request({
    url: '/news/update',
    method: 'post',
    data:{
      content,
      title,
      news_id,
    }
  })
}

export const addNewsImg = (data) => request({
  url: '/img/addNews',
  method: 'POST',
  data
})